<?php

session_start();
$number = $_POST['number'];
$fid =$_POST['fid'];
$id = $_SESSION['id'];
if (empty($_SESSION['id'])){
    echo "<script>alert('未登录!');window.location='login.php';</script>";
}else {
    if ($_SESSION['perssime'] == 1) {
        echo "<script>alert('管理员无法进行购物!');window.location='flowerDetail.php?fid=".$fid."';</script>";
    } else {
        include_once("mysql_conn.php");
        (new mysql_conn())->add_upadate("insert into shopcart(flowerid,userid,number) values(" . $fid . "," . $id . "," . $number . ")");
        echo "<script>alert('添加成功!');window.location='cart.php';</script>";
    }
}
?>